<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%
  item = deleted_item
  url_asset_string = item.asset_string

  # This is pretty hacky, but the controller expects an asset string that it
  # can split into a scope and an id, and it expects the scope to be a method
  # it can call on the context (in this case a course).  I'm fixing it here so
  # we don't have a colon in the url.  See ContextController#undelete
  url_asset_string = url_asset_string.gsub('quizzes:', '')
%>
<li class="item">
  <div class="links">
    <a class="restore_link btn" href="<%= context_url(@context, :context_undelete_item_url, url_asset_string) %>">{{#t}}restore{{/t}}</a>
  </div>
  <div class="name">
    <% if item.is_a?(Enrollment) %>
      <%= item.short_name %> - <%= item.user.name %>
    <% elsif item.respond_to?(:name) %>
      <%= item.name %>
    <% elsif item.respond_to?(:title) %>
      <%= item.title %>
    <% else %>
      <%= item.class.to_s %>:<%= item.id %>
    <% end %>
  </div>
  <div class="type">
    <%= item.class.to_s %>
  </div>
  <div class="details">
    <% if item.respond_to?(:description) %>
      <%= HtmlTextHelper.strip_and_truncate(item.description, :max_length => 200) %>
    <% elsif item.respond_to?(:message) %>
      <%= HtmlTextHelper.strip_and_truncate(item.message, :max_length => 200) %>
    <% end %>
  </div>
  <table class="dates">
    <tr>
      <td>{{#t}}created{{/t}}</td>
      <td><%= datetime_string(item.created_at) %></td>
    </tr><tr>
      <td>{{#t}}last updated{{/t}}</td>
      <td><%= datetime_string(item.updated_at) %></td>
    </tr>
  </table>
</li>
